<?php
/**
 * Created by xiaosong
 * E-mail:4155433@gmail.com
 * Date: 2018/12/28
 * Time: 9:43
 */

namespace app\api\controller;

use Workerman\Worker;
use GatewayWorker\Register;
use GatewayWorker\BusinessWorker;
use GatewayWorker\Gateway;
class Run
{

    /**
     * 构造函数
     * @access public
     */
    public function __construct()
    {

        //初始化各个GatewayWorker

        //初始化register
        new Register('text://0.0.0.0:1236');

        //初始化 bussinessWorker 进程
        $worker = new BusinessWorker();
        $worker->name = 'xiaosongAppBusinessWorker';
        $worker->count = 4;
        $worker->registerAddress = '127.0.0.1:1236';
        //设置处理业务的类,此处制定Events的命名空间
        $worker->eventHandler = '\app\api\controller\Events';

        // 初始化 gateway 进程
        $gateway = new Gateway("tcp://0.0.0.0:10115");
        $gateway->name = 'xiaosongAppGateway';
        $gateway->count = 4;
        $gateway->lanIp = '127.0.0.1';
        $gateway->startPort = 2900;
        $gateway->registerAddress = '127.0.0.1:1236';

        //运行所有Worker;
        Worker::runAll();


    }
}